package com.ashapo.example;

public class Example012HasA {

    Operation op;// 类中含有其他类对象则称为聚合
    double pi = 3.14;

    double area(int radius) {
        op = new Operation();
        int rsquare = op.square(radius);// code reusability (i.e. delegates the
        // method call).
        return pi * rsquare;
    }

    public static void main(String[] args) {
        Example012HasA c = new Example012HasA();
        double result = c.area(5);
        System.out.println(result);
    }
}

class Operation {
    int square(int n) {
        return n * n;
    }
}
